package dubrouski.io;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 *
 * @author Stanislau Dubrouski
 */
public class FileWriter {

    public static void writeToFile(String fileName, String content) {
        File file = new File(fileName);

        try {
            FileOutputStream fop = new FileOutputStream(file);
            // if file doesn't exists, then create it
            if (!file.exists()) {
                file.createNewFile();
            }
            // get the content in bytes
            byte[] contentInBytes = content.getBytes();

            fop.write(contentInBytes);
            fop.flush();
            fop.close();

        } catch (IOException e) {
            //TODO
        }
    }
}
